'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller, jwt } = app;

  router.post('/api/user/login', controller.sys.user.login);
  router.get('/api/user/info', jwt, controller.sys.user.getCurUserInfo);

  router.post('/api/change/psw', jwt, controller.sys.user.changePsw);
  router.post('/api/reset/psw', jwt, controller.sys.user.resetPsw);
  // 上传文件
  router.post('/api/file', controller.sys.file.upload);

  router.get('/api/user/page', jwt, controller.sys.user.page);
  router.post('/api/user/create', jwt, controller.sys.user.create);
  router.post('/api/user/update', jwt, controller.sys.user.update);
  router.post('/api/user/delete', jwt, controller.sys.user.delete);

  router.get('/api/role/query', jwt, controller.sys.role.query);
  router.get('/api/role/page', jwt, controller.sys.role.page);
  router.post('/api/role/create', jwt, controller.sys.role.create);
  router.post('/api/role/update', jwt, controller.sys.role.update);
  router.post('/api/role/delete', jwt, controller.sys.role.delete);
  //manage菜单
  router.get('/api/manage/status', jwt, controller.manage.status);
  router.get('/api/manage/page', jwt, controller.manage.page);
  router.post('/api/manage/create', jwt, controller.manage.create);
  router.post('/api/manage/update', jwt, controller.manage.update);
  router.post('/api/manage/delete', jwt, controller.manage.delete);
  router.get('/api/manage/query', jwt, controller.manage.query);
  //warranty菜单
  // router.post('/api/warranty/count', controller.warranty.count);
  router.get('/api/warranty/every', jwt, controller.warranty.every);
  router.get('/api/warranty/today', jwt, controller.warranty.today);
  router.get('/api/warranty/page', jwt, controller.warranty.page);
  router.post('/api/warranty/create', jwt, controller.warranty.create);
  router.post('/api/warranty/update', jwt, controller.warranty.update);
  router.post('/api/warranty/delete', jwt, controller.warranty.delete);
  router.post('/api/warranty/checkrepair', jwt, controller.warranty.checkrepair);
  //maintain菜单
  // router.get('/api/maintain/page', jwt, controller.maintain.page)
  router.get('/api/maintain/myMaintain', jwt, controller.maintain.myMaintain)
  router.post('/api/maintain/handleReceive', jwt, controller.maintain.handleReceive)
  router.post('/api/maintain/myMaintainDelete', jwt, controller.maintain.myMaintainDelete)
  router.post('/api/maintain/myMaintainUpdate', jwt, controller.maintain.myMaintainUpdate)
  // 查询所有菜单
  router.get('/api/menu/query/tree', jwt, controller.sys.menu.queryTree);
  // 添加菜单
  router.post('/api/menu/create', jwt, controller.sys.menu.create);
  // 修改菜单
  router.post('/api/menu/update', jwt, controller.sys.menu.update);
  // 删除菜单
  router.post('/api/menu/delete', jwt, controller.sys.menu.delete);
  // 更新角色菜单
  router.post('/api/role/menu/update', jwt, controller.sys.menu.setRoleMenu);
  // 根据角色id查询菜单
  router.get('/api/role/menu', jwt, controller.sys.menu.getRoleMenu);
  // 获取当前用户菜单
  router.get('/api/user/menu', jwt, controller.sys.menu.getCurUserMenu);
  // 通过角色获取对应的用户
  router.get('/api/users/by/role', jwt, controller.sys.user.getUsersByRole);


};
